package br3akr.DeadlyDinnerParty.Server.Engine;

import java.net.*;
import java.util.HashSet;
import java.util.Set;
import java.io.*;

import br3akr.DeadlyDinnerParty.Server.World.World;

public class Server {
	public static World world;
	public static boolean testing;
	private static Set<String> testNames;
	
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = null;
        boolean listening = true;
        testing = true;
        testNames = new HashSet<String>();
        world = new World();
        
        if (testing) {
        	testNames.add("Test1");
        	testNames.add("Test2");
        	testNames.add("Test3");
        }

        try {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e) {
            System.err.println("Could not listen on port: 4444.");
            System.exit(-1);
        }

        while (listening)
        	new ServerThread(serverSocket.accept(), world).start();

        serverSocket.close();
    }
    
    public static boolean isTestName(String name) {
    	if (name != null) {
	    	for (String t : testNames) {
	    		if (name.equals(t)) {
	    			return true;
	    		}
	    	}
    	}
    	return false;
    }
}